package cn.tworice.mybatis.util;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import java.util.AbstractMap;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class MyBatisPlusUtils {

    public static <T> Map<String,Object> buildResultMap(Page<T> page){
        return Stream.of(
                new AbstractMap.SimpleEntry<>("total", page.getTotal()),
                new AbstractMap.SimpleEntry<>("list", page.getRecords())
        ).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
    }


}
